/**
 * 
 */
package top.lcpsky.flashcards.common.factory;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

/**   
 * @ClassName:  HttpContext   
 * @author: lcp
 * @date:   2020年7月8日 下午3:34:44   
 *     
 * @Copyright: 2020 www.ankept.com Inc. All rights reserved. 
 */
public class HttpContext {
    /**
     * 获取当前请求的Request对象
     *
     * @Date 2018/7/23 下午3:44
     */
    public static HttpServletRequest getRequest() {
        ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        if (requestAttributes == null) {
            return null;
        } else {
            return requestAttributes.getRequest();
        }
    }
}
